package logic

import (
	"context"
	"manage/models/mysql"

	"manage/managerpc/internal/svc"
	"manage/managerpc/managerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ManageAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewManageAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ManageAddLogic {
	return &ManageAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ManageAddLogic) ManageAdd(in *managerpc.ManageAddRequest) (*managerpc.ManageAddResponse, error) {
	// todo: add your logic here and delete this line

	manage := mysql.Manage{
		UserId:     in.UserId,
		Image:      in.Image,
		ManageName: in.ManageName,
		Num:        int(in.Num),
	}
	mysql.DB.Create(&manage)
	return &managerpc.ManageAddResponse{
		ManageId: int64(manage.ID),
	}, nil
}
